package com.lynx.controller;

import java.util.Date;

import com.lynx.core.BizException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.lynx.controller.model.User;

/**
 * @author chris.liu
 * @version 4/9/14 2:43 PM
 */
@Controller("topNavBarController")
@RequestMapping(produces = "text/plain;charset=UTF-8")
public class TopNavBarController {

	@RequestMapping(value = "/index", method = RequestMethod.GET)
	public ModelAndView index() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("index");
		return modelAndView;
	}

	@RequestMapping(value = "/contact_us", method = RequestMethod.GET)
	public ModelAndView contract() throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("contact_us");
        throw new BizException("just a test");
//		return modelAndView;
	}

	@RequestMapping(value = "/about", method = RequestMethod.GET)
	public ModelAndView about() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("about");
		User user = new User();
		user.setName("chris");
		user.setCreateTime(new Date());
		modelAndView.addObject("user", user);
		modelAndView.addObject("msg", "hello world");
		return modelAndView;
	}

    @RequestMapping(value = "/404", method = RequestMethod.GET)
    public ModelAndView notfound() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("404");
        return modelAndView;
    }

}
